home *** CD-ROM | disk | FTP | other *** search
/ CD BIT 75 / CD BIT 75.iso / Software / mysql-4.0.22-win / data1.cab / Development / include / m_string.h < prev    next >
Encoding:
C/C++ Source or Header  |  2004-10-28  |  7.7 KB  |  259 lines

  1. /* Copyright (C) 2000 MySQL AB
  2.  
  3.    This program is free software; you can redistribute it and/or modify
  4.    it under the terms of the GNU General Public License as published by
  5.    the Free Software Foundation; either version 2 of the License, or
  6.    (at your option) any later version.
  7.  
  8.    This program is distributed in the hope that it will be useful,
  9.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  10.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  11.    GNU General Public License for more details.
  12.  
  13.    You should have received a copy of the GNU General Public License
  14.    along with this program; if not, write to the Free Software
  15.    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
  16.  
  17. /* There may be prolems include all of theese. Try to test in
  18.    configure with ones are needed? */
  19.  
  20. /*  This is needed for the definitions of strchr... on solaris */
  21.  
  22. #ifndef _m_string_h
  23. #define _m_string_h
  24. #ifndef __USE_GNU
  25. #define __USE_GNU                /* We want to use stpcpy */
  26. #endif
  27. #if defined(HAVE_STRINGS_H)
  28. #include <strings.h>
  29. #endif
  30. #if defined(HAVE_STRING_H)
  31. #include <string.h>
  32. #endif
  33.  
  34. /* Correct some things for UNIXWARE7 */
  35. #ifdef HAVE_UNIXWARE7_THREADS
  36. #undef HAVE_STRINGS_H
  37. #undef HAVE_MEMORY_H
  38. #define HAVE_MEMCPY
  39. #ifndef HAVE_MEMMOVE
  40. #define HAVE_MEMMOVE
  41. #endif
  42. #undef HAVE_BCMP
  43. #undef bcopy
  44. #undef bcmp
  45. #undef bzero
  46. #endif /* HAVE_UNIXWARE7_THREADS */
  47. #ifdef _AIX
  48. #undef HAVE_BCMP
  49. #endif
  50.  
  51. /*  This is needed for the definitions of bzero... on solaris */
  52. #if defined(HAVE_STRINGS_H) && !defined(HAVE_mit_thread)
  53. #include <strings.h>
  54. #endif
  55.  
  56. /*  This is needed for the definitions of memcpy... on solaris */
  57. #if defined(HAVE_MEMORY_H) && !defined(__cplusplus)
  58. #include <memory.h>
  59. #endif
  60.  
  61. #if !defined(HAVE_MEMCPY) && !defined(HAVE_MEMMOVE)
  62. # define memcpy(d, s, n)    bcopy ((s), (d), (n))
  63. # define memset(A,C,B)        bfill((A),(B),(C))
  64. # define memmove(d, s, n)    bmove ((d), (s), (n))
  65. #elif defined(HAVE_MEMMOVE)
  66. # define bmove(d, s, n)        memmove((d), (s), (n))
  67. #else
  68. # define memmove(d, s, n)    bmove((d), (s), (n)) /* our bmove */
  69. #endif
  70.  
  71. /* Unixware 7 */
  72. #if !defined(HAVE_BFILL)
  73. # define bfill(A,B,C)           memset((A),(C),(B))
  74. # define bmove_allign(A,B,C)    memcpy((A),(B),(C))
  75. #endif
  76.  
  77. #if !defined(HAVE_BCMP)
  78. # define bcopy(s, d, n)        memcpy((d), (s), (n))
  79. # define bcmp(A,B,C)        memcmp((A),(B),(C))
  80. # define bzero(A,B)        memset((A),0,(B))
  81. # define bmove_allign(A,B,C)    memcpy((A),(B),(C))
  82. #endif
  83.  
  84. #if defined(__cplusplus) && !defined(OS2)
  85. extern "C" {
  86. #endif
  87.  
  88. #if defined(HAVE_STPCPY) && !defined(HAVE_mit_thread)
  89. #define strmov(A,B) stpcpy((A),(B))
  90. #ifndef stpcpy
  91. extern char *stpcpy(char *, const char *);    /* For AIX with gcc 2.95.3 */
  92. #endif
  93. #endif
  94.  
  95. extern char NEAR _dig_vec[];        /* Declared in int2str() */
  96.  
  97. #ifdef BAD_STRING_COMPILER
  98. #define strmov(A,B)  (memccpy(A,B,0,INT_MAX)-1)
  99. #else
  100. #define strmov_overlapp(A,B) strmov(A,B)
  101. #define strmake_overlapp(A,B,C) strmake(A,B,C)
  102. #endif
  103.  
  104. #ifdef BAD_MEMCPY            /* Problem with gcc on Alpha */
  105. #define memcpy_fixed(A,B,C) bmove((A),(B),(C))
  106. #else
  107. #define memcpy_fixed(A,B,C) memcpy((A),(B),(C))
  108. #endif
  109.  
  110. #ifdef MSDOS
  111. #undef bmove_allign
  112. #define bmove512(A,B,C) bmove_allign(A,B,C)
  113. #define my_itoa(A,B,C) itoa(A,B,C)
  114. #define my_ltoa(A,B,C) ltoa(A,B,C)
  115. extern    void bmove_allign(gptr dst,const gptr src,uint len);
  116. #endif
  117.  
  118. #if (!defined(USE_BMOVE512) || defined(HAVE_purify)) && !defined(bmove512)
  119. #define bmove512(A,B,C) memcpy(A,B,C)
  120. #endif
  121.  
  122. #ifdef HAVE_purify
  123. #include <assert.h>
  124. #define memcpy_overlap(A,B,C) \
  125. DBUG_ASSERT((A) <= (B) || ((B)+(C)) <= (A)); \
  126. bmove((byte*) key,(byte*) from,(size_t) length);
  127. #else
  128. #define memcpy_overlap(A,B,C) memcpy((A), (B), (C))
  129. #endif /* HAVE_purify */
  130.  
  131.  
  132.     /* Prototypes for string functions */
  133.  
  134. #if !defined(bfill) && !defined(HAVE_BFILL)
  135. extern    void bfill(gptr dst,uint len,pchar fill);
  136. #endif
  137.  
  138. #if !defined(bzero) && !defined(HAVE_BZERO)
  139. extern    void bzero(gptr dst,uint len);
  140. #endif
  141.  
  142. #if !defined(bcmp) && !defined(HAVE_BCMP)
  143. extern    int bcmp(const char *s1,const char *s2,uint len);
  144. #endif
  145. #ifdef HAVE_purify
  146. extern    int my_bcmp(const char *s1,const char *s2,uint len);
  147. #undef bcmp
  148. #define bcmp(A,B,C) my_bcmp((A),(B),(C))
  149. #endif
  150.  
  151. #ifndef bmove512
  152. extern    void bmove512(gptr dst,const gptr src,uint len);
  153. #endif
  154.  
  155. #if !defined(HAVE_BMOVE) && !defined(bmove)
  156. extern    void bmove(char *dst, const char *src,uint len);
  157. #endif
  158.  
  159. extern    void bmove_upp(char *dst,const char *src,uint len);
  160. extern    void bchange(char *dst,uint old_len,const char *src,
  161.              uint new_len,uint tot_len);
  162. extern    void strappend(char *s,uint len,pchar fill);
  163. extern    char *strend(const char *s);
  164. extern  char *strcend(const char *, pchar);
  165. extern    char *strfield(char *src,int fields,int chars,int blanks,
  166.                int tabch);
  167. extern    char *strfill(my_string s,uint len,pchar fill);
  168. extern    uint strinstr(const char *str,const char *search);
  169. extern  uint r_strinstr(reg1 my_string str,int from, reg4 my_string search);
  170. extern    char *strkey(char *dst,char *head,char *tail,char *flags);
  171. extern    char *strmake(char *dst,const char *src,uint length);
  172. #ifndef strmake_overlapp
  173. extern    char *strmake_overlapp(char *dst,const char *src, uint length);
  174. #endif
  175.  
  176. #ifndef strmov
  177. extern    char *strmov(char *dst,const char *src);
  178. #endif
  179. extern    char *strnmov(char *dst,const char *src,uint n);
  180. extern    char *strsuff(const char *src,const char *suffix);
  181. extern    char *strcont(const char *src,const char *set);
  182. extern    char *strxcat _VARARGS((char *dst,const char *src, ...));
  183. extern    char *strxmov _VARARGS((char *dst,const char *src, ...));
  184. extern    char *strxcpy _VARARGS((char *dst,const char *src, ...));
  185. extern    char *strxncat _VARARGS((char *dst,uint len, const char *src, ...));
  186. extern    char *strxnmov _VARARGS((char *dst,uint len, const char *src, ...));
  187. extern    char *strxncpy _VARARGS((char *dst,uint len, const char *src, ...));
  188.  
  189. /* Prototypes of normal stringfunctions (with may ours) */
  190.  
  191. #ifdef WANT_STRING_PROTOTYPES
  192. extern char *strcat(char *, const char *);
  193. extern char *strchr(const char *, pchar);
  194. extern char *strrchr(const char *, pchar);
  195. extern char *strcpy(char *, const char *);
  196. extern int strcmp(const char *, const char *);
  197. #ifndef __GNUC__
  198. extern size_t strlen(const char *);
  199. #endif
  200. #endif
  201. #ifndef HAVE_STRNLEN 
  202. extern uint strnlen(const char *s, uint n);
  203. #endif
  204.  
  205. #if !defined(__cplusplus)
  206. #ifndef HAVE_STRPBRK
  207. extern char *strpbrk(const char *, const char *);
  208. #endif
  209. #ifndef HAVE_STRSTR
  210. extern char *strstr(const char *, const char *);
  211. #endif
  212. #endif
  213. extern int is_prefix(const char *, const char *);
  214.  
  215. /* Conversion rutins */
  216.  
  217. #ifdef USE_MY_ITOA
  218. extern char *my_itoa(int val,char *dst,int radix);
  219. extern char *my_ltoa(long val,char *dst,int radix);
  220. #endif
  221.  
  222. extern char *llstr(longlong value,char *buff);
  223. #ifndef HAVE_STRTOUL
  224. extern long strtol(const char *str, char **ptr, int base);
  225. extern ulong strtoul(const char *str, char **ptr, int base);
  226. #endif
  227.  
  228. extern char *int2str(long val,char *dst,int radix);
  229. extern char *int10_to_str(long val,char *dst,int radix);
  230. extern char *str2int(const char *src,int radix,long lower,long upper,
  231.              long *val);
  232. #if SIZEOF_LONG == SIZEOF_LONG_LONG
  233. #define longlong2str(A,B,C) int2str((A),(B),(C))
  234. #define longlong10_to_str(A,B,C) int10_to_str((A),(B),(C))
  235. #undef strtoll
  236. #define strtoll(A,B,C) strtol((A),(B),(C))
  237. #define strtoull(A,B,C) strtoul((A),(B),(C))
  238. #ifndef HAVE_STRTOULL
  239. #define HAVE_STRTOULL
  240. #endif
  241. #ifndef HAVE_STRTOLL
  242. #define HAVE_STRTOLL
  243. #endif
  244. #else
  245. #ifdef HAVE_LONG_LONG
  246. extern char *longlong2str(longlong val,char *dst,int radix);
  247. extern char *longlong10_to_str(longlong val,char *dst,int radix);
  248. #if (!defined(HAVE_STRTOULL) || defined(HAVE_mit_thread)) || defined(NO_STRTOLL_PROTO)
  249. extern longlong strtoll(const char *str, char **ptr, int base);
  250. extern ulonglong strtoull(const char *str, char **ptr, int base);
  251. #endif
  252. #endif
  253. #endif
  254.  
  255. #if defined(__cplusplus) && !defined(OS2)
  256. }
  257. #endif
  258. #endif
  259.